<?php 
namespace app\common\model;
class Car extends Common{
	protected $insert = ['addtime'=>SYS_TIME,'depth'=>4];
	protected function getAddtimeAttr($value, $data){
		return $value ? date("Y-m-d H:i",$value) : '未知';
	}
	protected function getBandAttr($value, $data){
		return model("Cartype")->where('id', $data['pid'])->value('fullname');
	}
	protected function getThumbAttr($value){
		if(strpos($value,"http://") !== false){
			return $value;
		}
		else{
			return $value ? rtrim(APP_URL,"/").'/'.$value : '';
		}
	}
	protected function getPnameAttr($value, $data){
		return model("Cartype")->where('id', $data['pid'])->value('title');
	}
	protected function getAlldataAttr($value, $data){
		$arr = [0=>'显示',1=>'隐藏'];
		$data['hidename'] = $arr[$data['hide']];
		$data['pname'] = $data['pid'] ? model("Cartype")->where('id', $data['pid'])->value('title') : '顶级分类';
		return $data;
	}
}